package cn.lhjl.day10.Annotation;

import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.sql.PreparedStatement;
import java.util.Properties;
public class Practice {
    @MyAnno(className = "cn.lhjl.day10.Annotation.Student",methodName = "game")
    public static void main(String[] args) {

        try {
            Class<Practice> practiceClass = Practice.class;
            Method main = practiceClass.getMethod("main", String[].class);
            MyAnno aImp = main.getAnnotation(MyAnno.class);
            String methodName = aImp.methodName();
            String className = aImp.className();
            Class aClass = Class.forName(className);
            Method method1 = aClass.getMethod(methodName);
            Object o = aClass.newInstance();
            method1.invoke(o);


        } catch (InstantiationException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (InvocationTargetException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }

    }
}
